#include <rtthread.h>
#include <rtdevice.h>
#include "platform.h"
#include "servoio.h"
#include "system.h"
#include "control.h"
#include "alarm.h"

int main(){
    system_startup(RT_NULL);
    sensors_init(RT_NULL);
    stepper_init(RT_NULL);
    esc_init(RT_NULL);

    static uint8_t controld_stack[512];
    static struct rt_thread controld_thread;
    rt_thread_init(&controld_thread, "tctld", controld, RT_NULL, controld_stack, sizeof(controld_stack), 12, 2);
    rt_thread_startup(&controld_thread);

    static uint8_t alarmd_stack[512];
    static struct rt_thread alarmd_thread;
    rt_thread_init(&alarmd_thread, "talarmd", alarmd, RT_NULL, alarmd_stack, sizeof(alarmd_stack), 13, 2);
    rt_thread_startup(&alarmd_thread);

    static uint8_t messaged_stack[512];
    static struct rt_thread messaged_thread;
    rt_thread_init(&messaged_thread, "tmsgd", messaged, RT_NULL, messaged_stack, sizeof(messaged_stack), 14, 2);
    rt_thread_startup(&messaged_thread);

    return RT_EOK;
}
